<%@ page language="java" contentType="text/html; UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="loginPRO.LoginPRO2"%>
<%@ page import="loginPRO.LoginReservation"%>
<%@ page import="registration.DataBase"%>
<%@ page import="reservation.DB_Reservation"%>
<%@page import="admin.Admin"%>

<%
// w celu poprawnie dzialajacej sesji:
response.setHeader("Cache-Control","no-store"); 
response.setHeader("Pragma","no-cache"); 
response.setDateHeader ("Expires", 0); 

String myname =  (String)session.getAttribute("maly"); //pobieramy sesje (login)

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="Stylesheet" type="text/css" href="../../style/style2.css" />
	
<title>Index</title>



</head>
<body>
<% 
if(myname!=null){
%>
<table id=main align=center valign=top width=1100 height=540 border=0>
<tr height=50 id=panelek>
<td width=5><td width=820 valign=top><td width=270>
<%

 out.println("Witaj  <b>"+myname+"</b>, <a href=\"wyloguj.jsp\" >wyloguj</a>");
 out.println( "<td width=5><tr><td width=5><td width=820>" );

%>
<tr valign=top><td width=5><td width=820 valign=top id=main>

<%
	//admin
	if("admin".equals(myname)){
	%>
	
	<table id="show" rules="all">
  <tr>
    <th id="show">Id Klienta</th>
    <th id="show">Numer pokoju</th>
     <th id="show">Cena</th>
    <th id="show">Data przyjazdu</th>
     <th id="show">Data wyjazdu</th>
     <th id="show">Data rezerwacji</th>
    
  </tr>
  
    <% 
    Admin ad = new Admin();
   
    //sprawdzanie getów
    if("yes".equals(request.getParameter("update_room"))){
    
    	 ad.changeRoomToFree();
    	
    }
    if("yes".equals(request.getParameter("aktualne_rezerwacje"))){
    
		
    	ad.showCurrentReservation(out);
    	
    }
    if("yes".equals(request.getParameter("historia_rezerwacji"))){
    	ad.showReservation(request, response, out);
    }
    
		
		%>
  
</table>
	
	<%	
	}

	if("yes".equals(request.getParameter("show"))){
		
		Admin adm = new Admin();
		String id = request.getParameter("id_client");
		int id_client = Integer.parseInt(id);

		adm.showClient(id_client, out, request);
	}






	if("yes".equals(request.getParameter("rezerwacja"))){
		
		java.sql.Date data1 = (java.sql.Date) session.getAttribute("dejta1");
		java.sql.Date data2 = (java.sql.Date)session.getAttribute("dejta2");
		String price = (String)session.getAttribute("prajse");
        int cena = Integer.parseInt(price);
        String id_room = (String)session.getAttribute("id");
        int id_rom = Integer.parseInt(id_room);
        
        
        DataBase x = new DataBase();
        int id_clients = x.getId_client(myname);
        
        DB_Reservation y = new DB_Reservation();
        y.addToDB(id_clients, id_rom, cena, data1, data2);
        y.updateRoom(id_rom);
        
        out.println("<a href=\"../confirm.jsp?fromIndex=yes&login="+myname+"\" >Kontynuuj rezerwacje</a>");
        //String kontynuuj="../confirm.jsp?fromIndex=yes&login="+myname;
        //out.println("<embed src=../../swf/kontynuuj.swf?kontynuuj="+kontynuuj+" quality=high wmode=transparent bgcolor=#0033ff width=350 height=60 name=moje_zamowienia align=middle allowScriptAccess=sameDomain type=application/x-shockwave-flash pluginspage=http://www.macromedia.com/go/getflashplayer /></object>");
		//out.println(kontynuuj);
        
	}

	if("yes".equals(request.getParameter("zamowienie"))){
		LoginReservation.show(myname, out);
			//LoginReservation.showPersonalInfo(myname, out);
	
	}
	if("yes".equals(request.getParameter("dane"))){
		
		LoginReservation.showPersonalInfo(myname, out);
	
	}
	

%>           
            
<td width=270 id=menu valign=top>
<%

//admin
if("admin".equals(myname)){

	String aktualne_rezerwacje="index.jsp?aktualne_rezerwacje=yes";
	out.println("<embed src=../../swf/aktualne_rezerwacje.swf?aktualne_rezerwacje="+aktualne_rezerwacje+" quality=high wmode=transparent bgcolor=#0033ff width=300 height=60 name=moje_zamowienia align=middle allowScriptAccess=sameDomain type=application/x-shockwave-flash pluginspage=http://www.macromedia.com/go/getflashplayer /></object>");
	
	String historia_rezerwacji = "index.jsp?historia_rezerwacji=yes";
	out.println("<embed src=../../swf/historia_rezerwacji.swf?historia_rezerwacji="+historia_rezerwacji+" quality=high wmode=transparent bgcolor=#0033ff width=300 height=60 name=moje_zamowienia align=middle allowScriptAccess=sameDomain type=application/x-shockwave-flash pluginspage=http://www.macromedia.com/go/getflashplayer /></object>");
	

}
else
{
	
	String moje_zamowienia="index.jsp?zamowienie=yes";
	out.println("<embed src=../../swf/moje_zamowienia.swf?moje_zamowienia="+moje_zamowienia+" quality=high wmode=transparent bgcolor=#0033ff width=300 height=60 name=moje_zamowienia align=middle allowScriptAccess=sameDomain type=application/x-shockwave-flash pluginspage=http://www.macromedia.com/go/getflashplayer /></object>");
	String nowa_rezerwacja = "../reservation.jsp";
	out.println("<embed src=../../swf/nowa_rezerwacja.swf?nowa_rezerwacja="+nowa_rezerwacja+" quality=high wmode=transparent bgcolor=#0033ff width=300 height=60 name=moje_zamowienia align=middle allowScriptAccess=sameDomain type=application/x-shockwave-flash pluginspage=http://www.macromedia.com/go/getflashplayer /></object>");
	String moje_dane = "index.jsp?dane=yes";
	out.println("<embed src=../../swf/moje_dane.swf?moje_dane="+moje_dane+" quality=high wmode=transparent bgcolor=#0033ff width=300 height=60 name=moje_zamowienia align=middle allowScriptAccess=sameDomain type=application/x-shockwave-flash pluginspage=http://www.macromedia.com/go/getflashplayer /></object>");

}

%>


<td width=5>
</table>


<%
}
else 
{
out.println( "<td width=5><tr><td width=5><td width=820>" );
if("yes".equals(request.getParameter("rezerwacja"))){
	LoginPRO2.formularzLogowania(out, "checkLogin.jsp?rezerwacja=yes", "../register.jsp");}
else {
	LoginPRO2.formularzLogowania(out, "checkLogin.jsp", "../register.jsp");
}
out.println("<br><center><a href=\"../index1.jsp\" >strona glowna</a>");



}
%>

</body>
</html>